package com.shxzz.shortlink.project.controller;

import com.shxzz.shortlink.project.common.convention.result.Result;
import com.shxzz.shortlink.project.common.convention.result.Results;
import com.shxzz.shortlink.project.service.UrlInfoService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author shxzz
 * @create 2023-12-21-16:10
 * @description 源地址信息获取控制层
 */
@RestController
@RequiredArgsConstructor
public class UrlInfoController {

    private final UrlInfoService urlInfoService;

    /**
     * 获取目标网址标题
     */
    @GetMapping("/api/short-link/v1/title")
    public Result<String> getTargetUrlTitle(@RequestParam("url") String targetUrl) {
        return Results.success(urlInfoService.getTargetUrlTitle(targetUrl));
    }
}
